﻿using System;
using UnityEngine;

public class USTimelineContainer : MonoBehaviour
{
    [SerializeField]
    private Transform affectedObject;
    [SerializeField]
    private int index = -1;

    public void AddNewTimeline(USTimelineBase timeline)
    {
        base.transform.parent = base.transform;
    }

    public static int Comparer(USTimelineContainer a, USTimelineContainer b)
    {
        return a.Index.CompareTo(b.Index);
    }

    public void ManuallySetTime(float sequencerTime)
    {
        foreach (USTimelineBase base2 in this.Timelines)
        {
            base2.ManuallySetTime(sequencerTime);
        }
    }

    public void ProcessTimelines(float sequencerTime)
    {
        foreach (USTimelineBase base2 in this.Timelines)
        {
            base2.Process(sequencerTime);
        }
    }

    public void RenameTimelineContainer()
    {
        if (this.affectedObject != null)
        {
            base.name = this.affectedObject.name+"的时间线";
        }
    }

    public Transform AffectedObject
    {
        get
        {
            return this.affectedObject;
        }
        set
        {
            this.affectedObject = value;
            this.RenameTimelineContainer();
        }
    }

    public int Index
    {
        get
        {
            return this.index;
        }
        set
        {
            this.index = value;
        }
    }

    public USSequencer Sequence
    {
        get
        {
            USSequencer component = base.transform.parent.GetComponent<USSequencer>();
            if (component == null)
            {
                Debug.LogWarning(base.name + "有问题：父节点没有添加USSequencer组件. " + base.name + "的父节点是: " + base.transform.parent.name);
            }
            return component;
        }
    }

    public USTimelineBase[] Timelines
    {
        get
        {
            return base.GetComponentsInChildren<USTimelineBase>();
        }
    }
}

